package cn.snmp.mutual.uk.stack;

import java.io.*;

class AsnPduSequence extends AsnSequence {
    private static final String version_id = "@(#)$Id: AsnPduSequence.java,v 3.10 2006/01/17 17:43:54 birgit Exp $ Copyright Westhawk Ltd";
    boolean snmpv3Discovery;

    AsnPduSequence(final InputStream in, final int len, final int pos) throws IOException {
        super(in, len, pos);
        this.snmpv3Discovery = false;
    }

    int getReqId() {
        final AsnInteger rid = (AsnInteger) this.getObj(0);
        return rid.getValue();
    }

    int getWhatError() {
        final AsnInteger estat = (AsnInteger) this.getObj(1);
        return estat.getValue();
    }

    int getWhereError() {
        final AsnInteger estat = (AsnInteger) this.getObj(2);
        return estat.getValue();
    }

    AsnSequence getVarBind() {
        return (AsnSequence) this.getObj(3);
    }

    @Override
    AsnObject findPdu() {
        return this;
    }

    int getValue() {
        final AsnSequence varBind = (AsnSequence) this.getObj(3);
        final AsnSequence varPair = (AsnSequence) varBind.getObj(0);
        final AsnInteger val = (AsnInteger) varPair.getObj(1);
        final int value = val.getValue();
        return value;
    }

    boolean hadError() {
        return 0 != this.getWhatError();
    }

    boolean isSnmpv3Discovery() {
        return this.snmpv3Discovery;
    }

    void setSnmpv3Discovery(final boolean b) {
        this.snmpv3Discovery = b;
    }
}
